package teach.aistar.service.impl;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import teach.aistar.mapper.UserMapper;

import teach.aistar.model.entity.User;
import teach.aistar.service.IUserService;

import java.util.List;
@Service
public class UserServiceImpl implements IUserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> findAll() {
        return userMapper.findAll();
    }

    @Override
    public User getById(Integer uid) {
       return userMapper.getById(uid);
    }


    @Override
    public User login(String uname) {
        return userMapper.getByUsername(uname);
    }

    @Override
    public User getByUsername(String uname) {
        return userMapper.getByUsername(uname);
    }

    @Override
    public void add(User user) {
       User user2 =userMapper.getByUsername(user.getUname()) ;

       if(user2==null)
       {
           userMapper.add(user);
       }


       }

    @Override
    public int update(String uname, String pwd,Integer uId) {
        int count = userMapper.update(uname,pwd,uId);
        return count;
    }
}



